1   package uba.db.table;
2   
3   import java.util.ArrayList;
4   import java.util.List;
5   
6   import junit.framework.TestCase;
7   import uba.db.column.CharColumnSpecification;
8   import uba.db.column.IntegerColumnSpecification;
9   
10  /***
11   * Test de unidad para {@link TableSchemaBuilder}.
12   * 
13   * @version $Revision: 1.1 $
14   */
15  public class TableSchemaBuilderTest extends TestCase {
16      private static final String PROFESSORS_TABLE_NAME = "Professors";
17      private static final IntegerColumnSpecification ID_COLUMN_SPEC = new IntegerColumnSpecification(
18              "id");
19      private static final CharColumnSpecification NAME_COLUMN_SPEC = new CharColumnSpecification(
20              "name", 20);
21      private TableSchema tableSchema;
22  
23      /***
24       * @see junit.framework.TestCase#setUp()
25       */
26      protected void setUp() throws Exception {
27          super.setUp();
28  
29          List columnSpecifications = new ArrayList();
30          columnSpecifications.add(ID_COLUMN_SPEC);
31          columnSpecifications.add(NAME_COLUMN_SPEC);
32  
33          tableSchema = new TableSchema(PROFESSORS_TABLE_NAME, columnSpecifications);
34      }
35  
36      /***
37       * Test: construir una instancia concreta de {@link TableSchema}.
38       */
39      public void testBuild() throws Exception {
40          TableSchemaBuilder builder = new TableSchemaBuilder(PROFESSORS_TABLE_NAME);
41          builder.addColumn(ID_COLUMN_SPEC);
42          builder.addColumn(NAME_COLUMN_SPEC);
43  
44          TableSchema result = builder.build();
45          assertEquals(tableSchema, result);
46      }
47  }